part of 'header.dart';

class HomeTopView extends StatelessWidget {
  HomeTopView({Key? key}) : super(key: key);

  final controller = Get.find<HomeController>();
  @override
  Widget build(BuildContext context) {
    return SizedBox(
        height: 381.w,
        child: Stack(
          children: [
            Positioned(
                width: Get.width,
                height: 240.5.w,
                child: Obx(
                  () => CarouselSlider(
                    options: CarouselOptions(
                      autoPlay: true,
                      disableCenter: true,
                      viewportFraction: 1,
                      // scrollDirection: Axis.vertical,
                    ),
                    items: controller.state.swiperItems.value
                        .asMap()
                        .map((key, value) => MapEntry(
                            key,
                            InkWell(
                              child: loadImage(
                                  url: value.picUrl, fit: BoxFit.fill),
                            )))
                        .values
                        .toList(),
                  ),
                )),
            // child: Obx(() => Swiper(
            //       containerHeight: 240.5.w,
            //       containerWidth: Get.width,
            //       itemCount: controller.state.swiperItems.length,
            //       itemBuilder: (context, index) {
            //         var item = controller.state.swiperItems.value[index];
            //         return InkWell(
            //           child: loadImage(url: item.picUrl),
            //         );
            //       },
            //     )),
            // ),

            Positioned(
                top: 214.w,
                height: 167.w,
                width: Get.width,
                child: const HeaderMenuView()),
          ],
        ));
  }
}

class HomeAppBar extends StatelessWidget {
  HomeAppBar({Key? key}) : super(key: key);
  final controller = Get.find<HomeController>();
  final locationCtrl = Get.find<LocationController>();
  @override
  Widget build(BuildContext context) {
    return Obx(() => Container(
        color: Color.fromARGB(controller.state.alpha.value, 255, 255, 255),
        padding: EdgeInsets.only(top: SizeFit.statusBarHeight),
        width: Get.width,
        child: Row(
          children: [
            Visibility(
                child: InkWell(
              onTap: controller.actionLocation,
              child: Container(
                width: 87.w,
                alignment: Alignment.center,
                child: Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Icon(
                      Icons.location_on,
                      size: 14.w,
                      color: ColorsUtil.title,
                    ),
                    Text(
                      locationCtrl.md.value.city ?? '北京',
                      style: pfMediumStyle(
                          color: ColorsUtil.title, fontSize: font14),
                    ),
                    Icon(
                      IconUtil.arrow_down,
                      size: 12.w,
                      color: ColorsUtil.title,
                    ),
                  ],
                ),
              ),
            )),
            searchFadeBar(hintText: '请输入关键词', width: 235.w),
            IconButton(
                key: controller.state.addKey,
                onPressed: controller.actionAdd,
                icon: Icon(
                  IconUtil.add_circle,
                  size: 20.w,
                  color: ColorsUtil.title,
                ))
          ],
        )));
  }
}
